<extend name="Base/common"/>

<block name="style">
<link href="__CSS__/stylesheet.css" rel="stylesheet">
<link href="__CSS__/login.css" rel="stylesheet">
</block>

<block name="header">
<header>
	<div class="container">
		<section class="menu-top">
			<div class="fl">
				<section class="header-logo-search">
					<div class="logo fl">
						<img src="__IMG__/logo.png"/>
					</div>
				</section>
			</div>
        </section>
	</div>
</header>
</block>
<block name="body">
<div class="container main">
	<p class="section-header">忘记密码</p>
	<div class="section-forgotten">
		<form action="{:U('User/forgotten')}" class="section-form" autocomplete="off">
			<div class="form-group">
				<label class="input-addon phone"></label>
				<input class="form-control" name="username" id="forgottenmobile" type="text" placeholder="手机号">
			</div>
			<div class="form-group">
				<input class="form-control input-verify forgoten_verify" name="verify" type="text" placeholder="验证码">
				<a href="javascript:;" class="btn message forgoten_sendbtn">点击获取验证码</a>
			</div>
			<div class="form-group">
				<label class="input-addon key"></label>
				<input class="form-control" name="password" type="password"  placeholder="设置密码">
			</div>
			<div class="form-group">
				<label class="input-addon key"></label>
				<input class="form-control" name="repassword" type="password"  placeholder="重复密码">
			</div>
			<div class="form-group">
				<a class="btn ajax-post" href="javascript;;" target-form="section-form">确认</a>
			</div>
		</form>
	</div>
</div>
</block>
<block name="script">
<script type="text/javascript">
var time = 120;
function btntext() {
	time--;	
	if(time < 0) {
		time = 120;
		self.val('获取短信验证码');
		self.removeClass('disabled');
	} else {
		self.val(time + '秒重新发送');
		setTimeout("btntext()", 1000);
	}
}

$(function(){
	$('.forgoten_sendbtn').on('click', function(e){
		self = $(this);
		
		if (self.hasClass('disabled')) {
			return false;
		}
		
		self.addClass('disabled');		
		$.post('{:U('send/message')}', 'method=forgotten&mobile=' + encodeURIComponent($('#forgottenmobile').val()), function(data){
			if (data.status) {
				$('.forgoten_verify').val(data.code);
				self.val(time + '秒重新发送');
				setTimeout("btntext()", 1000);
			} else {
				updateAlert(data.info);
				self.removeClass('disabled');
			}
		}, "json");
	});
});
</script>
</block>